<!DOCTYPE html>
<html>
	<head>
	    <meta charset="utf-8">
	    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	    <title>运动会管理系统</title>
	    <link rel="stylesheet" href="../layui/css/layui.css">
	</head>
	<body>
		<form class="layui-form" action="">
		 
		  <div class="layui-form-item">
		    <label class="layui-form-label">项目编号</label>
		    <div class="layui-input-inline">
		      <input type="text" id="cnoA" name="cnoA" required lay-verify="required" placeholder="请输入项目编号" autocomplete="off" class="layui-input">
		    </div>
		    
		  </div>
		  
		  <div class="layui-form-item">
		    <label class="layui-form-label">项目名称</label>
		    <div class="layui-input-inline">
		      <input type="text" id = "cnA" name="cnA" required lay-verify="required" placeholder="请输入项目名称" autocomplete="off" class="layui-input">
		    </div>
		    
		  </div>
		  
			
		  <div class="layui-form-item">
		    <label class="layui-form-label">最大人数</label>
		    <div class="layui-input-inline">
		      <input type="number" id = "max" name="max" required lay-verify="required" placeholder="请输入最大人数" autocomplete="off" class="layui-input">
		    </div>		    
		  </div>
		  
		  <div class="layui-form-item">
		    <label class="layui-form-label">场地</label>
		    <div class="layui-input-inline">
		      <input type="text" id="placeA" name="placeA" required lay-verify="required" placeholder="请输入比赛场地" autocomplete="off" class="layui-input">
		    </div>		    
		  </div>
		  
		  <div class="layui-form-item">
		    <label class="layui-form-label">比赛时间</label>
		    <div class="layui-input-inline">
		      <input type="text" name="dateA" id = "dateA" required lay-verify="required" placeholder="请输入比赛时间" autocomplete="off" class="layui-input">
		    </div>		    
		  </div>
		  <div class="layui-form-item">
		    <div class="layui-input-block">
		      <button class="layui-btn" lay-submit lay-filter="updateComp">更新</button>
		    </div>
		  </div>
		</form>
		 
		<script src="../layui/layui.js"></script>
		<script>
		layui.use(['form','layer','laydate'] ,function(){
		  var form = layui.form;
		  var layer = layui.layer;
		  var $ = layui.$;
		  var form = layui.form;		
		  var date = layui.laydate;
		  date.render({
		  			  elem: '#dateA'					  
		  });
		  
		 
		  //监听提交
		  form.on('submit(updateComp)', function(data){
			console.log("->",data);  
		    layer.msg(JSON.stringify(data.field));
			//AJAX请求
			$.post("http://localhost:8080/updateComp",data.field,function(d){
				console.log(d);
				if(d!=true){
					layer.msg(d);
				}else{
					var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
					parent.layer.close(index); //再执行关闭
				}
			}
			
			);
			//取消form默认的action
		    return false;
		  });
		});
		</script>					      	    
		
	</body>
</html>